package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizCheckTitle;
import com.ruoyi.system.service.IBizCheckTitleService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检查清单Controller
 * 
 * @author gaofeng
 * @date 2025-07-08
 */
@Controller
@RequestMapping("/system/title")
public class BizCheckTitleController extends BaseController
{
    private String prefix = "system/title";

    @Autowired
    private IBizCheckTitleService bizCheckTitleService;

    @RequiresPermissions("system:title:view")
    @GetMapping()
    public String title()
    {
        return prefix + "/title";
    }

    /**
     * 查询检查清单列表
     */
    @RequiresPermissions("system:title:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizCheckTitle bizCheckTitle)
    {
        startPage();
        List<BizCheckTitle> list = bizCheckTitleService.selectBizCheckTitleList(bizCheckTitle);
        return getDataTable(list);
    }

    /**
     * 导出检查清单列表
     */
    @RequiresPermissions("system:title:export")
    @Log(title = "检查清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizCheckTitle bizCheckTitle)
    {
        List<BizCheckTitle> list = bizCheckTitleService.selectBizCheckTitleList(bizCheckTitle);
        ExcelUtil<BizCheckTitle> util = new ExcelUtil<BizCheckTitle>(BizCheckTitle.class);
        return util.exportExcel(list, "检查清单数据");
    }

    /**
     * 新增检查清单
     */
    @RequiresPermissions("system:title:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存检查清单
     */
    @RequiresPermissions("system:title:add")
    @Log(title = "检查清单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizCheckTitle bizCheckTitle)
    {
        return toAjax(bizCheckTitleService.insertBizCheckTitle(bizCheckTitle));
    }

    /**
     * 修改检查清单
     */
    @RequiresPermissions("system:title:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BizCheckTitle bizCheckTitle = bizCheckTitleService.selectBizCheckTitleById(id);
        mmap.put("bizCheckTitle", bizCheckTitle);
        return prefix + "/edit";
    }

    /**
     * 修改保存检查清单
     */
    @RequiresPermissions("system:title:edit")
    @Log(title = "检查清单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizCheckTitle bizCheckTitle)
    {
        return toAjax(bizCheckTitleService.updateBizCheckTitle(bizCheckTitle));
    }

    /**
     * 删除检查清单
     */
    @RequiresPermissions("system:title:remove")
    @Log(title = "检查清单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizCheckTitleService.deleteBizCheckTitleByIds(ids));
    }
}
